package com.ruoyi.production.service.impl.greenhousefilm;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.OrderAllocation;
import com.ruoyi.order.mapper.OrderAllocationMapper;
import com.ruoyi.production.domain.greenhousefilm.GreenhousefilmApply;
import com.ruoyi.production.mapper.greenhousefilm.GreenhousefilmApplyMapper;
import com.ruoyi.production.service.greenhousefilm.IGreenhousefilmApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 棚膜申请Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@Service
public class GreenhousefilmApplyServiceImpl implements IGreenhousefilmApplyService
{
    @Autowired
    private GreenhousefilmApplyMapper greenhousefilmApplyMapper;
    @Autowired
    private OrderAllocationMapper orderAllocationMapper;

    /**
     * 查询棚膜申请
     *
     * @param greenhousefilmApplyId 棚膜申请ID
     * @return 棚膜申请
     */
    @Override
    public GreenhousefilmApply selectGreenhousefilmApplyById(Long greenhousefilmApplyId)
    {
        return greenhousefilmApplyMapper.selectGreenhousefilmApplyById(greenhousefilmApplyId);
    }

    /**
     * 查询棚膜申请列表
     *
     * @param greenhousefilmApply 棚膜申请
     * @return 棚膜申请
     */
    @Override
    public List<GreenhousefilmApply> selectGreenhousefilmApplyList(GreenhousefilmApply greenhousefilmApply)
    {
        return greenhousefilmApplyMapper.selectGreenhousefilmApplyList(greenhousefilmApply);
    }

    /**
     * 新增棚膜申请
     *
     * @param greenhousefilmApply 棚膜申请
     * @return 结果
     */
    @Override
    public int insertGreenhousefilmApply(GreenhousefilmApply greenhousefilmApply)
    {
        Long orderAllocationId = greenhousefilmApply.getOrderAllocationId();
        OrderAllocation orderAllocation = orderAllocationMapper.selectOrderAllocationById(orderAllocationId);
        greenhousefilmApply.setOrderId(orderAllocation.getOrderId());













        greenhousefilmApply.setCreateTime(DateUtils.getNowDate());



        return greenhousefilmApplyMapper.insertGreenhousefilmApply(greenhousefilmApply);
    }

    /**
     * 修改棚膜申请
     *
     * @param greenhousefilmApply 棚膜申请
     * @return 结果
     */
    @Override
    public int updateGreenhousefilmApply(GreenhousefilmApply greenhousefilmApply)
    {
        greenhousefilmApply.setUpdateTime(DateUtils.getNowDate());
        return greenhousefilmApplyMapper.updateGreenhousefilmApply(greenhousefilmApply);
    }

    /**
     * 批量删除棚膜申请
     *
     * @param greenhousefilmApplyIds 需要删除的棚膜申请ID
     * @return 结果
     */
    @Override
    public int deleteGreenhousefilmApplyByIds(Long[] greenhousefilmApplyIds)
    {
        return greenhousefilmApplyMapper.deleteGreenhousefilmApplyByIds(greenhousefilmApplyIds);
    }

    /**
     * 删除棚膜申请信息
     *
     * @param greenhousefilmApplyId 棚膜申请ID
     * @return 结果
     */
    @Override
    public int deleteGreenhousefilmApplyById(Long greenhousefilmApplyId)
    {
        return greenhousefilmApplyMapper.deleteGreenhousefilmApplyById(greenhousefilmApplyId);
    }
}
